package com.xxx.video.commen.utils;

import android.text.TextUtils;

import androidx.annotation.ColorRes;

import com.xxx.video.VideoApplication;
import com.xxx.video.commen.configs.Constant;


public class ResourcesUtils {

    private static ResourcesUtils mResourcesUtils = null;

    private ResourcesUtils() {
    }

    public static ResourcesUtils getInstance() {
        if (mResourcesUtils == null) {
            synchronized (ResourcesUtils.class) {
                if (mResourcesUtils == null) {
                    mResourcesUtils = new ResourcesUtils();
                }
            }
        }
        return mResourcesUtils;
    }

    /**
     * get a color
     *
     * @param id Color res id
     * @return color
     */
    public int getColor(@ColorRes int id) {
        return VideoApplication.getInstance().getResources().getColor(id);
    }

    /**
     * get image path
     *
     * @param url url
     * @return path
     */
    public String getImagePath(String url) {
        if (TextUtils.isEmpty(url)) {
            return "";
        }
        if (url.contains("http")) {
            return url;
        }
        return Constant.resBeforeUrl + url;
    }

    /**
     * get download path
     *
     * @param url url
     * @return path
     */
    public String getDownloadPath(String url) {
        if (TextUtils.isEmpty(url)) {
            return "";
        }
        if (url.contains("http")) {
            return url;
        }
        return Constant.resBeforeUrl + url;
    }
}
